import 'package:flutter/material.dart';
import 'package:maintenancerecord/pages/records/DessertDataSource.dart';

class RecordDataTable extends StatefulWidget {
  List<DataRow> rows;
  RecordDataTable({super.key, required this.rows});

  @override
  State<RecordDataTable> createState() => _RecordDataTableState();
}

class _RecordDataTableState extends State<RecordDataTable> {

  late List<DataRow> dataRows = [];

  @override
  void initState() {
    super.initState();
  }


  @override
  void didUpdateWidget(RecordDataTable oldWidget) {
    setState(() {
      dataRows = widget.rows;
    });
  }

  @override
  Widget build(BuildContext context) {
    double win_w = MediaQuery.of(context).size.width - 75;
    return Container(
        // color: Colors.grey,
        width: win_w,
        height: 220,
        child: SingleChildScrollView(
          child: DataTable(
            headingRowColor: MaterialStateProperty.all(Colors.white70),
            headingRowHeight: 35,
            dataRowHeight: 32,
            border: TableBorder(),
            columns: <DataColumn>[
              DataColumn(
                label: const Text('保修人员'),
              ),
              DataColumn(
                label: const Text('故障类型'),
                // tooltip: '人物主要出场的作品.',
              ),
              DataColumn(
                label: const Text('处理状态'),
              ),
              DataColumn(
                label: const Text('服务人员'),
              ),
              DataColumn(
                label: const Text('最后维修时间'),
              ),
            ],
            rows: dataRows
          ),
        ));
  }

}
